package com.fowo.api.sys.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.common.model.R;
import com.fowo.api.sys.model.SysDataActivitySearch;
import com.fowo.api.sys.model.SysDataActivityItemVo;
import com.fowo.api.sys.model.SysDataActivityParam;
import com.fowo.api.sys.service.SysDataActivityService;

import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "数据活动")
@RestController
@RequestMapping("/api/sys/data-activity")
public class SysDataActivityController {

    @Resource
    private SysDataActivityService sysDataActivityService;

    @GetMapping("page")
    public R<Page<SysDataActivityItemVo>> pageSearch(SysDataActivitySearch search) {
        return R.data(() -> sysDataActivityService.searchPage(search));
    }

    @Schema(description = "获取数据活动配置参数")
    @GetMapping("param")
    public R<SysDataActivityParam> getParam() {
        return R.data(() -> sysDataActivityService.getParam());
    }

    @Schema(description = "设置数据活动配置参数")
    @PutMapping("param")
    public R updateParam(@RequestBody SysDataActivityParam param) {
        return R.ok(() -> sysDataActivityService.updateParam(param));
    }

    @DeleteMapping("clean")
    public R clean() {
        return R.ok(() -> sysDataActivityService.clean());
    }
}
